﻿
using System;

namespace GECS.Input {
	
	/// <summary>
	/// This class can be used to note mouse input from any class in the game which
	/// is aautomatically updated by the GInput class.
	/// </summary>
    public class GMouse {
        
		/// <summary>
		/// Constant for mouse moved left.
		/// </summary>
        public const int MOUSE_MOVE_LEFT = 0;
        
        /// <summary>
        /// Constant for mouse moved right.
        /// </summary>
        public const int MOUSE_MOVE_RIGHT = 1;
        
        /// <summary>
        /// Constant for mouse moved up.
        /// </summary>
        public const int MOUSE_MOVE_UP = 2;
        
        /// <summary>
        /// Constant for mouse moved down.
        /// </summary>
        public const int MOUSE_MOVE_DOWN = 3;
        
        /// <summary>
        /// Constant for mouse wheel moved up.
        /// </summary>
        public const int MOUSE_WHEEL_UP = 4;
        
        /// <summary>
        /// Constant for mouse wheel moved down.
        /// </summary>
        public const int MOUSE_WHEEL_DOWN = 5;
        
        /// <summary>
        /// Constant for the left mouse button.
        /// </summary>
        public const int MOUSE_BUTTON_1 = 6;
        
        /// <summary>
        /// Constant for the middle mouse button.
        /// </summary>
        public const int MOUSE_BUTTON_2 = 7;
        
        /// <summary>
        /// Constant for the right mouse button.
        /// </summary>
        public const int MOUSE_BUTTON_3 = 8;
        
        /// <summary>
        /// Constant for the mouse click.
        /// </summary>
        public const int MOUSE_CLICKED = 9;
        
        /// <summary>
        /// Constant for the no. of mouse codes defined.
        /// </summary>
        public const int NUM_MOUSE_CODES = 10;

        /// <summary>
        /// The x-position of the mouse.
        /// </summary>
        public static int X = 0;
        
        /// <summary>
        /// The y-position of the mouse.
        /// </summary>
        public static int Y = 0;

        /// <summary>
        /// The x-position of the recent mouse click.
        /// </summary>
        public static int MOUSE_CLICK_X = 0;
        
        /// <summary>
        /// The y-position of the recent mouse click.
        /// </summary>
        public static int MOUSE_CLICK_Y = 0;

        /// <summary>
        /// Checks if the mouse has been clicked (A press and a release).
        /// </summary>
        /// <returns>True if clicked. Else False.</returns>
        public static bool IsClicked() {
            return GInput.MOUSE_ACTIONS[MOUSE_CLICKED].IsPressed();
        }

        /// <summary>
        /// Checks if a mouse button is pressed (held down).
        /// </summary>
        /// <param name="button">Mouse code for the button.</param>
        /// <returns>True if pressed. Else False.</returns>
        public static bool IsPressed(int button) {
            return GInput.MOUSE_ACTIONS[button].IsPressed();
        }

        /// <summary>
        /// Gets you the distance moved by the mouse in a direction.
        /// </summary>
        /// <param name="mouseCode">The mouse code with direction.</param>
        /// <returns>The distance moved in the direction.</returns>
        public static int GetDistance(int mouseCode) {
            return GInput.MOUSE_ACTIONS[mouseCode].Amount;
        }

    }
}
